package org.mycub.server.mock.bike.factories;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.mycub.server.mock.bike.models.BikeStationLight;

public class BikeStationLightFactory {

	public static int MAX_STATIONS = 20;
	public static int MAX_SLOTS = 40;
	public static int MAX_STRING_LENGTH = 20;

	public BikeStationLightFactory() {

	}

	public List<BikeStationLight> createMockStations(double lon, double lat,
			double radius) {

		Random rand = new Random();
		int nb = rand.nextInt(MAX_STATIONS);
		List<BikeStationLight> list = new ArrayList<BikeStationLight>();

		for (int i = 0; i < nb; i++) {
			BikeStationLight bs = new BikeStationLight();

			bs.setId(i);
			bs.setAvailableBikes(rand.nextInt(MAX_SLOTS));
			bs.setFreeSlots(rand.nextInt(MAX_SLOTS));
			bs.setOpen(rand.nextInt(2) == 1);
			
			list.add(bs);
		}

		return list;
	}

	public String generateRandomString() {
		char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();
		StringBuilder sb = new StringBuilder();
		Random random = new Random();
		int stringLength = random.nextInt(MAX_STRING_LENGTH);
		for (int i = 0; i < stringLength; i++) {
			char c = chars[random.nextInt(chars.length)];
			sb.append(c);
		}
		return sb.toString();
	}
}
